﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	用户签到页面
'	2011.11.2

Sub main
	Dim userid,body_,a,rs,timeLast,times,timeInterval,timeDefault
	userid=user_array(0)
	timeDefault=CDate("1900-01-01")
	a=getData("a")
	checkLogin()'验证登录
	hu.title = "用户签到"
	body_ = checkMsg()'信息
	body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_user.asp","会员中心")&"-用户签到[/div]"
	If a="" Then
		Set rs=hu.conn("select top 1 savetime,subtype from 74hu_transaction where type=3 and userid="&userid)
		If Not rs.eof Then
			times = rs("subtype")
			timeLast=rs("savetime")
			timeInterval = DateDiff("d", timeLast, time_now)'初始化 savetime 为 null,此时 timeInterval 为空值
			If timeLast<>"" Then'表明还没签到过
				body_ = body_ & "上次签到:"&fordate(timeLast)
				If timeInterval>1 Then'超过2天不不继续累加
					hu.conn("update 74hu_transaction set subtype=0 where type=3 and userid="&userid)
				Else
					body_ = body_ & "，已连续"&times&"天签到"
				End If
			Else
				body_ = body_ & "快来签到获取奖励！！"
			End If
			If timeInterval=0 Then
				body_ = body_ & "<br/>今天已签到过了,请明天再来吧"
			Else
				body_ = body_ & "<br/>"&hu.url("bbs_sign.asp?a=1","马上签到获取奖励!")
			End If
		Else
			hu.conn("insert into 74hu_transaction ([userid],[type],[subtype],[savetime]) values("&userid&",3,0,null)")
			body_ = body_ & "快来签到获取奖励！！<br/>" &hu.url("bbs_sign.asp?a=1","马上签到获取奖励!")
		End If
		body_ = body_ & "<br/>[div=tip]温馨提示:<br/>1、普通签到奖励："&bbsMoney&","&bbsPoint&",经验("&amtSign&")<br/>"&_
			"2、7天以上奖励："&bbsMoney&","&bbsPoint&",经验("&amtSign7&")[/div]"
		Set rs=hu.conn("select top 5 t.userid,u.name,t.savetime from 74hu_transaction t inner join 74hu_user u on (u.id=t.userid) where t.type=3 and savetime<>null order by t.savetime desc")
		If Not rs.eof Then
			body_ = body_ & "最新签到:<br/>"
			Do While Not rs.eof
				body_ = body_ & getDiffFromNow(rs("savetime"))&"，"& hu.url("bbs_user.asp?id="&rs("userid"),rs("name"))&"签到<br/>"
				rs.movenext
			Loop
			body_ = body_ & "..."
		End If
	Else
		Set rs=hu.conn("select top 1 savetime,subtype from 74hu_transaction where type=3 and userid="&userid)
		If Not rs.eof Then
			timeInterval = DateDiff("d", rs("savetime"), time_now)'初始化 savetime 为 null,此时 timeInterval 为空值
			times = rs("subtype")
			If timeInterval>1 Then'超过2天不不继续累加
				hu.conn("update 74hu_transaction set [subtype]=1,[savetime]='"&time_now&"' where type=3 and userid="&userid)
				Call setUserAmount(userid, amtSign)'加金币积分经验
				body_ = body_ & "签到成功！获得奖励："&bbsMoney&","&bbsPoint&",经验("&amtSign&")"
			ElseIf timeInterval=0 Then
				body_ = body_ & "今天已签到过了,请明天再来吧"
			Else
				hu.conn("update 74hu_transaction set [subtype]=[subtype]+1,[savetime]='"&time_now&"' where type=3 and userid="&userid)
				If times<6 Then'连续7天额外奖励
					Call setUserAmount(userid, amtSign)'加金币积分经验
					body_ = body_ & "签到成功！获得奖励："&bbsMoney&","&bbsPoint&",经验("&amtSign&")"
				Else
					Call setUserAmount(userid, amtSign7)'加金币积分经验
					body_ = body_ & "7天以上签到成功！获得奖励："&bbsMoney&","&bbsPoint&",经验("&amtSign7&")"
				End If
			End If
		Else
			body_ = body_ & "参数错误"
		End If
	End If
	hu.body = comUbb(body_)
End Sub

%>